<template>
	<view style="margin: 20px;">
		<view class="headerCard">
			<view class="headerContent">过磅单号：{{formData.poundsNo}}</view>
			<uni-forms :modelValue="formData" ref="formData" style="padding: 10px;">
				<uni-forms-item label="智能判级：" name="intelligence">
					<uni-easyinput v-model="formData.intelligence" :disabled="true" />
				</uni-forms-item>
				<uni-forms-item label="智能价格：">
					<uni-easyinput v-model="formData.deprice" :disabled="true" />
				</uni-forms-item>
				<uni-forms-item label="智能扣重(T)：">
					<uni-easyinput v-model="formData.intelligenceJudging" :disabled="true" />
				</uni-forms-item>
				<uni-forms-item label="人工判级: " required name="Tdegrade">
					<uni-data-select v-model="formData.Tdegrade" :localdata="gradeList" />
				</uni-forms-item>
				<uni-forms-item label="加减价格：" name="Tdeprice" required>
					<uni-easyinput v-model="formData.Tdeprice" type="number" />
				</uni-forms-item>
				<uni-forms-item label="扣重(T)：" name="manualJudging" required>
					<uni-easyinput v-model="formData.manualJudging" type="number" />
				</uni-forms-item>
				<uni-forms-item label="扣价：" name="Tdemoney" required>
					<uni-easyinput v-model="formData.Tdemoney" type="number" />
				</uni-forms-item>
			</uni-forms>
			<view class="button-group">
				<button size="mini" @click="cancelClick">取消</button>
				<button type="primary" plain="true" size="mini" @click="okClick">确定</button>
			</view>
		</view>
	</view>
</template>
<script>
	import receiptList from "../../common/ReceiptList.js"
	export default {
		data() {
			return {
				formData: {
					id: '',
					poundsNo: '',
					intelligenceJudging: '',
					specs: '',
					degrade: '',
					deprice: '',
					Tdeprice: '',
					Tdegrade: null,
					Tdemoney: '',
					manualJudging: '',
					updateBy: "",
					updateTime: ''
				},
				rules: {
					Tdeprice: {
						rules: [{
							required: true,
							errorMessage: '请输入加减价格'
						}]
					},
					Tdegrade: {
						rules: [{
							required: true,
							errorMessage: '请选择级别',
						}]
					},
					manualJudging: {
						rules: [{
							required: true,
							errorMessage: '请输入扣重'
						}]
					},
					Tdemoney: {
						rules: [{
							required: true,
							errorMessage: '请输入扣价'
						}]
					}
				},
				gradeList: [{

						text: '钢筋颗粒≥12mm',
						value: '钢筋颗粒|≥12mm'
					},
					{
						text: '特级≥16mm',
						value: '特级|≥16mm'
					},
					{
						text: '特级10-16mm',
						value: '特级|10-16mm'
					},
					{
						text: '特级6-10mm',
						value: '特级|6-10mm'
					},
					{
						text: '特级4-6mm',
						value: '特级|4-6mm'
					},
					{
						text: '特级2-4mm',
						value: '特级|2-4mm'
					},
					{
						text: '重废一≥16mm',
						value: '重废一|≥16mm'
					},
					{
						text: '重废二12-16mm',
						value: '重废二|12-16mm'
					},
					{
						text: '中废一8-12mm',
						value: '中废一|8-12mm'
					},
					{
						text: '中废二6-8mm',
						value: '中废|二6-8mm'
					},
					{
						text: '轻废4-6mm',
						value: '轻废|4-6mm'
					},
					{
						text: '轻废2-4mm',
						value: '轻废|2-4mm'
					}
				]
			}
		},
		onReady() {
			this.$refs.formData.setRules(this.rules);
		},
		onLoad(option) {
			let jsonStr = option.item;
			this.formData = JSON.parse(jsonStr);

		},
		methods: {
			cancelClick() {
				uni.switchTab({
					url: '../ReceipList/ReceipList'
				})
			},
			okClick() {
				var _this = this;
				uni.showModal({
					title: '审核提示',
					content: "审核后无法修改, 是否继续?",
					confirmText: '确定',
					cancelText: '取消',
					success: function(res) {
						if (res.confirm) {
							console.log(_this.formData)
							_this.$refs.formData.validate().then(res => {
								receiptList.submitSteel({
									id: _this.formData.id,
									degrade: _this.formData.Tdegrade,
									deprice: _this.formData.Tdeprice,
									manualJudging: _this.formData.manualJudging,
									demoney: _this.formData.Tdemoney,
								}).then(data => {
									if (data.code == 0) {
										uni.showToast({
											icon: "success",
											title: "提交成功",
											duration: 1000,
											success: function() {
												uni.switchTab({
													url: '../ReceipList/ReceipList'
												});
											}
										});

									}
								}).catch(e => {
									uni.showToast({
										icon: "error",
										title: "提交失败",
										duration: 1000
									});
								});
							})
						}
					}
				});
			}
		}
	}
</script>

<style>
	.headerCard {
		border: 1px solid #eaeaea;
		width: 100%;
	}

	.headerContent {
		border-bottom: 1px solid #eaeaea;
		padding: 10px 0 10px 10px;
		width: 100%;
		box-sizing: border-box;
	}

	/deep/.uni-forms-item__label {
		width: 90px !important;
	}

	/deep/.uni-date {
		width: 220px !important;
	}

	/deep/.uni-date__x-input {
		height: 36px !important;
	}

	/deep/.uni-easyinput {
		width: 220px !important;
	}

	/deep/.uni-select {
		width: 220px !important;
	}

	/deep/.uni-stat__select {
		padding: 0 !important;
	}

	/deep/.uni-select__input-box {
		width: 200px !important;
	}

	/deep/.uni-forms-item__inner {
		padding-bottom: 10px !important;
	}

	.button-group {
		margin-bottom: 10px;
		display: flex;
		justify-content: space-around;
	}
</style>